package com.jdk8datedemo;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

public class ChronoUnitDemo {
    public static void main(String[] args) {
        //当前本地年月日
        LocalDateTime now = LocalDateTime.now();
        System.out.println(now);

        //生日的年月日
        LocalDateTime birthday = LocalDateTime.of(2000, 1, 1,0,00,00,00);
        System.out.println(birthday);

        System.out.println(ChronoUnit.YEARS.between(birthday,now));
        System.out.println(ChronoUnit.MONTHS.between(birthday,now));
        System.out.println(ChronoUnit.WEEKS.between(birthday,now));
        System.out.println(ChronoUnit.DAYS.between(birthday,now));
        System.out.println(ChronoUnit.HOURS.between(birthday,now));
        System.out.println(ChronoUnit.MINUTES.between(birthday,now));
        System.out.println(ChronoUnit.MILLIS.between(birthday,now));
        System.out.println(ChronoUnit.MICROS.between(birthday,now));
        System.out.println(ChronoUnit.HALF_DAYS.between(birthday,now));
        System.out.println(ChronoUnit.DECADES.between(birthday,now));
        System.out.println(ChronoUnit.CENTURIES.between(birthday,now));
        System.out.println(ChronoUnit.MILLENNIA.between(birthday,now));
        System.out.println(ChronoUnit.ERAS.between(birthday,now));
    }
}
